Post

Replies

Boosts

Views

Activity

Reply to get domain name of mobile account.
Hi, I've followed you very useful command and found a field that represent the user full name (base name + domain) even when active directory is unreachable. the field is kODAttributeTypeAltSecurityIdentities and I can definitely recommend using it to extract domain name. 		NSError *err; 		 		ODNode * searchNode = [ODNode nodeWithSession:[ODSession defaultSession] name:@"/Search" error:&err]; 		if (err) { 				writeLog(LOG_ERROR, "error getting Search node : %s", [[err description] UTF8String]); 				return L""; 		} 		 		ODRecord *record = [searchNode recordWithRecordType:kODRecordTypeUsers 																									 name:username 																						 attributes:nil error:&err]; 		if (!record) { 				writeLog(LOG_ERROR, "error: couldn't find user %S in Search node : %s", username.c_str(), [[err description] UTF8String]); 				return L""; 		} 		ODQuery *query = [[ODQuery alloc] initWithNode:searchNode 																		forRecordTypes:kODRecordTypeUsers 																				 attribute:kODAttributeTypeRecordName 																				 matchType:kODMatchEqualTo 																			 queryValues:username 																	returnAttributes:@[kODAttributeTypeAltSecurityIdentities] 																		maximumResults:10 																						 error:&err]; 		 		NSArray* results = [query resultsAllowingPartial:NO error:&err]; 		for(ODRecord *record in results) { 				NSString * domainName = (NSString *)[record valuesForAttribute:kODAttributeTypeAltSecurityIdentities error:nil][0]; 				if (domainName != nil) { 						return [[domainName componentsSeparatedByString: @":"] lastObject]; 				} 		}
Nov ’20