首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS MDM:用于iOS MDM和支持MDM iOS应用程序的通用密钥/id

iOS MDM:用于iOS MDM和支持MDM iOS应用程序的通用密钥/id
EN

Stack Overflow用户
提问于 2012-08-31 03:58:45
回答 1查看 1.2K关注 0票数 3

我正在从事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支持应用程序。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-06 12:20:20

你也可以使用wifi mac address替换UDID.The逻辑来获取mac地址,如下所示,你可以在你的支持iOS应用程序中使用它来获取mac地址。你可以在服务器端使用MDM命令wifi mac地址。

//.h文件

代码语言:javascript
复制
#import <Foundation/Foundation.h>

@interface MacAddress : NSObject

+ (NSString *)getMacAddress;

@end

//实现文件

代码语言:javascript
复制
#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;
}

@end
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12204535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档