我正在从事MDM解决方案的工作,我面临着UDID问题。我们有一个iOS应用程序,作为iOS MDM的支持应用程序,可以在iOS设备向我们的MDM服务器注册MDM后启动server.This支持应用程序。
在设备注册中,我们可以在服务器端获得设备UDID,并且我们将此设备UDID用作iOS MDM和iOS支持应用程序的公共密钥。要在支持应用程序的iOS中登录我们的MDM服务器,用户必须提供我们使用api [[UIDevice currentDevice] uniqueIdentifier]捕获的用户in、密码和UDID,因此对于身份验证,这3个参数是必需的。
但是苹果已经在iOS 5.0中弃用了设备UDID,所以我们不能在iOS应用程序中使用苹果API来捕获设备UDID。
现在我们需要一些公用密钥,这些公用密钥可以在iOS MDM证书中使用,也可以在支持iOS的应用程序中生成。这样,哪些用户已将iOS设备注册到MDM服务器,则应该只有该用户能够登录iOS支持应用程序。
发布于 2012-09-06 12:20:20
你也可以使用wifi mac address替换UDID.The逻辑来获取mac地址,如下所示,你可以在你的支持iOS应用程序中使用它来获取mac地址。你可以在服务器端使用MDM命令wifi mac地址。
//.h文件
#import <Foundation/Foundation.h>
@interface MacAddress : NSObject
+ (NSString *)getMacAddress;
@end//实现文件
#import "MacAddress.h"
#import <sys/socket.h>
#import <sys/sysctl.h>
#import <net/if.h>
#import <net/if_dl.h>
@implementation MacAddress
+ (NSString *)getMacAddress
{
int mgmtInfoBase[6];
char *msgBuffer = NULL;
size_t length;
unsigned char macAddress[6];
struct if_msghdr *interfaceMsgStruct;
struct sockaddr_dl *socketStruct;
NSString *errorFlag = NULL;
// Setup the management Information Base (mib)
mgmtInfoBase[0] = CTL_NET; // Request network subsystem
mgmtInfoBase[1] = AF_ROUTE; // Routing table info
mgmtInfoBase[2] = 0;
mgmtInfoBase[3] = AF_LINK; // Request link layer information
mgmtInfoBase[4] = NET_RT_IFLIST; // Request all configured interfaces
// With all configured interfaces requested, get handle index
if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0)
errorFlag = @"if_nametoindex failure";
else
{
// Get the size of the data available (store in len)
if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0)
errorFlag = @"sysctl mgmtInfoBase failure";
else
{
// Alloc memory based on above call
if ((msgBuffer = malloc(length)) == NULL)
errorFlag = @"buffer allocation failure";
else
{
// Get system information, store in buffer
if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
errorFlag = @"sysctl msgBuffer failure";
}
}
}
// Befor going any further...
if (errorFlag != NULL)
{
NSLog(@"Error: %@", errorFlag);
return errorFlag;
}
// Map msgbuffer to interface message structure
interfaceMsgStruct = (struct if_msghdr *) msgBuffer;
// Map to link-level socket structure
socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);
// Copy link layer address data in socket structure to an array
memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);
// Read from char array into a string object, into traditional Mac address format
NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
macAddress[0], macAddress[1], macAddress[2],
macAddress[3], macAddress[4], macAddress[5]];
//NSLog(@"Mac Address: %@", macAddressString);
// Release the buffer memory
free(msgBuffer);
return macAddressString;
}
@endhttps://stackoverflow.com/questions/12204535
复制相似问题