Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:31:16+00:00 2026-06-06T02:31:16+00:00

I am trying to pull an LDAP jpegPhoto attribute from an openLDAP server using

  • 0

I am trying to pull an LDAP “jpegPhoto” attribute from an openLDAP server using a iOS openLDAP framework. The framework pulls the data as a dictionary of NSStrings.

I need to convert the NSString of “jpegPhoto” (which also appears to be base64 encoded) to UIImage, with the end result being that I display the jpegPhoto as the user’s image when they login.

More Info:

-(NSDictionary *)doQuery:(NSString *)query:(NSArray *)attrsToReturn {
    ...
    while(attribute){
        if ((vals = ldap_get_values_len(ld, entry, attribute))){
            for(int i = 0; vals[i]; i++){
                //Uncomment if you want to see all the values.
                //NSLog(@"%s: %s", attribute, vals[i]->bv_val);
                if ([resultSet objectForKey:[NSString stringWithFormat:@"%s",attribute]] == nil){
                    [resultSet setObject:[NSArray arrayWithObject:[NSString stringWithFormat:@"%s",vals[i]->bv_val]] forKey:[NSString stringWithFormat:@"%s",attribute]];
                }else{
                    NSMutableArray *array = [[resultSet objectForKey:[NSString stringWithFormat:@"%s",attribute]] mutableCopy];
                    [array addObject:[NSString stringWithFormat:@"%s",vals[i]->bv_val]];
                    [resultSet setObject:array forKey:[NSString stringWithFormat:@"%s",attribute]];
                }
            }
            ldap_value_free_len(vals);
        };
        ldap_memfree(attribute);
        attribute = ldap_next_attribute(ld, entry, ber);
    };
    ...
}

-(UIIMage *)getPhoto{
    NSString *query = [NSString stringWithFormat:@"(uid=%@)",self.bindUsername];
    NSArray *attrsToReturn = [NSArray arrayWithObjects:@"cn",@"jpegPhoto", nil];
    NSDictionary *rs = [self doQuery:query:attrsToReturn];
    NSString *photoString = [[rs objectForKey:@"jpegPhoto"] objectAtIndex:0];
    NSLog(@"The photoString is: %i %@",[photoString length],@"characters long"); //returns 4
    NSData *photoData = [NSData dataWithBase64EncodedString:photoString];
    UIImage *userPhoto = [UIImage imageWithData:photoData];
    return userPhoto;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.studentNameLabel.text = [NSString stringWithFormat:@"Hi %@!",[self.ldap getFullName]];
    self.studentPhotoImage.image = [self.ldap getPhoto];
    [self checkForProctor];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:31:17+00:00Added an answer on June 6, 2026 at 2:31 am

    Try this code

    NSData *dataObj = [NSData dataWithBase64EncodedString:beforeStringImage];
    UIImage *beforeImage = [UIImage imageWithData:dataObj];
    

    There are many similar questions in Stackoverflow.. Please refer the following links

    UIImage to base64 String Encoding

    UIImage from bytes held in NSString

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pull in data from a remote SQL Server. I can access
I am trying to pull 1 week data from sql server, then trying to
I am trying to pull some data from a server (I don't own the
I am trying to pull data from our Oracle datamart into R using RODBC.
I am trying to pull data from DBF files into my program using C#.
I'm currently trying to pull data from a database using a variable and then
I'm trying to pull data from my database using json in php. I have
I'm trying to pull data using a SqlDataReader, one column of which is in
I am trying to pull out data from the table I had from the
I am trying to pull data using an mysql query that requires that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.